package com.ttloner3.connectionpool;

import com.alibaba.druid.pool.*;
import com.alibaba.druid.support.hibernate.DruidConnectionProvider;
import org.junit.Test;


import javax.sql.DataSource;
import java.io.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

/**
 * @author TTLoner
 * @date 2021/6/25 19:19
 * @description
 */
public class YouCantStandThePowerOfNature {
    @Test
    public void getConnect() throws Exception {
//        DruidDataSource source = new DruidDataSource();
//        source.setUrl("jdbc:mysql://localhost:3306/test");
//        source.setUsername("root");
//        source.setPassword("root");
//        source.setDriverClassName("com.mysql.jdbc.Driver");
        Properties properties = new Properties();
        InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("druid.properties");
        properties.load(is);
        DataSource source = DruidDataSourceFactory.createDataSource(properties);
        Connection conn = source.getConnection();
        System.out.println(conn);
    }
}
